package com.waiting.serializable;

import java.io.ObjectStreamException;
import java.io.Serializable;

/**
 * @author bjweitingting
 * @description
 * @date 2018/8/23
 **/
public class User implements Serializable {

    private static final long serialVersionUID = -241560032527654570L;

    private static String username;
    private transient String passwd;



    public String getUsername() {
        return username;
    }

    public static void setUsername(String username) {
        User.username = username;
    }

    public String getPasswd() {
        return passwd;
    }

    public void setPasswd(String passwd) {
        this.passwd = passwd;
    }
    //序列化时，会调用该方法，可以在该方法中，对数据进行加解密
    private void writeObject(java.io.ObjectOutputStream stream)
            throws java.io.IOException
    {
        // "Encrypt"/obscure the sensitive data
        stream.defaultWriteObject();
    }

    //反序列化，会调用readObject方法
    private void readObject(java.io.ObjectInputStream stream)
            throws java.io.IOException, ClassNotFoundException
    {
        System.out.println("beidioayogn");
   //     stream.defaultReadObject();

        // "Decrypt"/de-obscure the sensitive data

    }
    private Object readResolve() throws ObjectStreamException {
        // instead of the object we're on,
        // return the class variable INSTANCE
        return null;
    }
}
